<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h2>{{reverseMsg}}</h2>
        <hr>
        <h4>{{computMsg()}}</h4>
        <input type="text" v-model="msg">
        <input type="button" value="点击" @click="num = 3">
        <hr>
        <input type="button" value="显示时间" @click="showDate">
        {{dateStr}}
    </div>

    <script>
        // var a = "2021年是牛年";
        // alert(a.split('').reverse().join(''));

        var vueObj = new Vue({
            el:"#app",
            data:{
              msg:"2021年是牛年",
                num:1,
                dateStr:""
            },
            methods:{
              computMsg(){
                  console.log("methods");
                  return this.msg.split('').reverse().join('');
              },
              getDate(){
                  return new Date();
              },
                showDate(){
                  this.dateStr =  this.getDate()+"------"+this.getDate1;
                }
            },
            computed:{
                reverseMsg(){
                    console.log("computed");
                    return this.msg.split('').reverse().join('');
                },
                getDate1(){
                    return new Date();
                }
            }
        });
    </script>
</body>
</html>